import java.io.IOException;


public class Main
{

    /**
     * @param args
     * @throws IOException 
     * @throws NumberFormatException 
     */
    public static void main(String[] args) throws NumberFormatException, IOException
    {
        if (args.length == 0)
        {
            printHelp();
            return;
        }
        else if (args[0].equals("-g"))
        {
            for (int i = 2; i < args.length; ++i)
            {
                Parser p = new GameParser(Integer.parseInt(args[1]), args[i]);
                p.parse();
            }
        }
        else if (args[0].equals("-p"))
        {
            for (int i = 1; i < args.length; ++i)
            {
                Parser p = new PeopleParser(args[i]);
                p.parse();
            }
        }
        else if (args[0].equals("-r"))
        {
            for (int i = 1; i < args.length; ++i)
            {
                Parser p = new RosterParser(args[i]);
                p.parse();
            }
        }
        else if (args[0].equals("-l"))
        {
            for (int i = 1; i < args.length; ++i)
            {
                Parser p = new PlayParser(args[i]);
                p.parse();
            }
            PlayParser.printAllBatters("batters.sql");
            PlayParser.printAllPitchers("pitchers.sql");
        }
        else if (args[0].equals("-o"))
        {
            for (int i = 1; i < args.length; ++i)
            {
                Parser p = new LogParser(args[i]);
                p.parse();
            }
        }
        else if (args[0].equals("-t"))
        {
            for (int i = 1; i < args.length; ++i)
            {
                Parser p = new TeamParser(args[i]);
                p.parse();
            }
        }
        else
        {
            printHelp();
            return;
        }
        
        System.out.println("Finished!");
    }

    private static void printHelp()
    {
        System.out.println("Usage:");
        System.out.println("-g <type> <gamelogs>");
        System.out.println("\t1: regular season, 2: divisonal series, 3: league championship series, 4: world series");
        System.out.println("-p <peoplefiles>");
        System.out.println("-r <rosterfiles>");
        System.out.println("-l <playfiles>");
        System.out.println("-t <teamfiles>");
    }
}
 
